import { request } from 'umi';

/** 店铺看板 */
export async function getShopBoardData() {
  return request(`/api/shop/order/data`, {
    method: 'GET',
    headers: {
      Action_Id: '600600000'
    }
  });
}

/** 店铺看板订单统计 */
export async function getShopOrderData(params: any) {
  return request(`/api/shop/order/data/1/limit/10000`, {
    method: 'GET',
    params
  });
}


/** 查询店铺列表（商城管理-导航管理需要） */
export async function getShopList({current = 1, pageSize = 10000, shop_status = '' }) {
  return request(`/api/mail/shop/${current}/limit/${pageSize}`, {
    method: 'GET',
    params: {
      shop_status
    }
  });
}
/** 查询店铺信息 600601000 */
export async function getShopInfo(status: string) {
  return request(`/api/shop/info?status=${status}`, {
    method: 'GET',
    headers: {
      Action_Id: '600601000'
    }
  });
}

/** 查询店铺信息 不带权限 */
export async function getShopInfo1() {
  return request(`/api/shop/info/for/other`, {
    method: 'GET',
  });
}

/** 修改店铺信息 600601001 */
export async function updateShopInfo(data: SHOPAPI.ShopInfo) {
  return request(`/api/shop/info`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: '600601001'
    }
  });
}

// 审批店铺信息(600601004)
export async function spShopInfo(data: SHOPAPI.ShopInfo) {
  return request(`/api/shop/approval/${data.approval_id}/${data.status}`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: '600601004'
    }
  });
}

/** 查询店铺装饰 600601002 */
export async function getShopLogo() {
  return request(`/api/shop/logo`, {
    method: 'GET',
    headers: {
      Action_Id: '600601002'
    }
  });
}

/** 修改店铺装饰 600601003 */
export async function updateShopLogo(data: {image_url: string; logo_url: string;}) {
  return request(`/api/shop/logo`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: '600601003'
    }
  });
}

/** 查询店铺商品列表(600602000) */
export async function getShopGoods(data: any) {
  return request(`/api/shop/goods/${data.current}/limit/${data.pageSize}`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: '600602000'
    }
  });
}

/** 查询店铺商品列表 */
export async function getShopGoodsByPage(data: any) {
  return request(`/api/mail/shop/goods/${data.current}/limit/${data.pageSize}`, {
    method: 'POST',
    data
  });
}

/** 批量删除商品(600602002, 600602007) */
export async function deleteShopGoods(shop_goods_ids: string[], single?: boolean) {
  return request(`/api/shop/goods/batch`, {
    method: 'PATCH',
    data: {
      shop_goods_ids
    },
    headers: {
      Action_Id: single ? '600602007' : '600602000'
    }
  });
}

/** 店铺添加商品(600602001) */
export async function addShopGoods(data: SHOPAPI.ShopGoods) {
  return request(`/api/shop/goods`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: '600602001'
    }
  });
}

/** 修改商品信息(600602006) */
export async function updateShopGoods(data: SHOPAPI.ShopGoods) {
  return request(`/api/shop/goods/${data.shop_goods_id}`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: '600602006'
    }
  });
}

/** 查询店铺商品详情 */
export async function getShopGoodsDetail(shop_goods_id: string) {
  return request(`/api/shop/goods/${shop_goods_id}`, {
    method: 'GET'
  });
}

/** 批量上架/下架商品或单个上架/下架(600602003,600602004,600602005) */
export async function updateShopGoodsStatus(shop_goods_ids: string[], goods_status: string, single?: boolean) {
  return request(`/api/shop/goods/${goods_status}/batch`, {
    method: 'PATCH',
    data: {
      shop_goods_ids
    },
    headers: {
      Action_Id: single ? '600602005' : goods_status === 'O' ? '600602003' : '600602004'
    }
  });
}




/** 查询分类列表-用于菜单(600603000) */
export async function getClassMenuList() {
  return request(`/api/shop/class/list`, {
    method: 'GET',
    headers: {
      Action_Id: '600603000'
    }
  });
}

/** 添加/编辑分类(600603001) */
export async function addModifyClass(data: any) {
  return request(`/api/shop/class`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: '600603001'
    }
  });
}

/** 查询分类列表-用于编辑(600603000) */
export async function getEditClassMenuList() {
  return request(`/api/shop/class/edit`, {
    method: 'GET'
  });
}

/** 编辑此分类下商品(600603002) */
export async function updateClassGoods(data: any) {
  return request(`/api/shop/class/goods`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: '600603002'
    }
  });
}

/** 删除此分类下选定商品(600603003) */
export async function deleteClassGoods(data: any) {
  return request(`/api/shop/class/goods`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: '600603003'
    }
  });
}


/** 查询商铺订单列表(600604000) */
export async function getShopOrderList(data: any) {
  return request(`/api/shop/order/${data.current}/limit/${data.pageSize}`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: '600604000'
    }
  });
}

/** 修改收货人信息(600604007) */
export async function updateReceiverInfo(data: {
  order_id: string;
  receiver: string;
  receiver_address: string;
  receiver_mobile: string;
}) {
  return request(`/api/shop/order/${data.order_id}/receive`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: '600604007'
    }
  });
}

/** 查询操作记录*/
export async function getOptRecordList(data: any) {
  return request(`/api/shop/order/${data.order_id}/operate/${data.current}/limit/${data.pageSize}`, {
    method: 'GET'
  });
}

/** 确认发货(600604005,600604008)*/
export async function doDelivery(data: {
  order_id: string;
  mail_id: string;
  mail_name: string;
  mail_no: string;
}, flag?: boolean) {
  return request(`/api/shop/order/${data.order_id}/mail`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: !flag ? '600604005' : '600604008'
    }
  });
}

/** 查询订单详情(600604003)*/
export async function getShopOrderDetail(order_id: string) {
  return request(`/api/shop/order/${order_id}`, {
    method: 'GET',
    headers: {
      Action_Id: '600604003'
    }
  });
}

/** 更新订单状态(600604005,600604006)*/
export async function updateOrderStatus(data: {
  order_id: string;
  order_status: string;
  remarks?: string;
  receiver?: string;
  receiver_mobile?: string;
}) {
  return request(`/api/shop/order/${data.order_id}/${data.order_status}?remarks=${data.remarks || ''}&receiver=${data.receiver || ''}&receiver_mobile=${data.receiver_mobile || ''}`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: data.order_status === 'C' ? '600604005' : '600604006'
    }
  });
}

/** 查询评论列表(600610001)*/
export async function getCommentsList(data: any) {
  return request(`/api/store/comment/${data.current}/limit/${data.pageSize}`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: '600610001'
    }
  });
}

/** 批量通过/拒绝评论信息(600610004,600610005) */
export async function batchUpdateComments(data: any) {
  return request(`/api/store/batch/edit/comment`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: data.Action_Id
    }
  });
}

/** 操作评论信息(600610002，600610003) */
export async function updateComments(data: any) {
  return request(`/api/store/edit/comment`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: data.Action_Id
    }
  });
}

/** 查询咨询列表(600611001)*/
export async function getConsultList(data: any) {
  return request(`/api/store/consult/${data.current}/limit/${data.pageSize}`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: '600611001'
    }
  });
}

/** 回复咨询信息(600611002, 600611003, 600611004, 600611005) */
export async function updateConsult(data: any) {
  return request(`/api/store/edit/consult`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: data.Action_Id
    }
  });
}

/** 批量关闭咨询信息(600611006) */
export async function batchUpdateConsult(data: any) {
  return request(`/api/store/batch/edit/consult`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: '600611006'
    }
  });
}

/** 查询投诉列表(600612001)*/
export async function getComplainList(data: any) {
  return request(`/api/store/complain/${data.current}/limit/${data.pageSize}`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: '600612001'
    }
  });
}

/** 关闭投诉信息(600612003) */
export async function closeComplain(data: any) {
  return request(`/api/store/close/complain/info`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: '600612003'
    }
  });
}

/** 批量关闭咨询信息(600612004) */
export async function batchCloseComplain(complain_ids: string[]) {
  return request(`/api/store/batch/close/complain/info`, {
    method: 'PATCH',
    data: {
      complain_ids
    },
    headers: {
      Action_Id: '600612004'
    }
  });
}

/** 添加投诉回复(600612005) */
export async function replay(data: any) {
  return request(`/api/store/add/complain/detail`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: '600612005'
    }
  });
}

/** 投诉沟通记录(600612002) */
export async function getComplainCommucation(complain_id: string) {
  return request(`/api/store/complain/detail/${complain_id}`, {
    method: 'GET',
    headers: {
      Action_Id: '600612002'
    }
  });
}

/** 查询投诉信息(600612010) */
export async function getComplainDetail(complain_id: string) {
  return request(`/api/store/complain/${complain_id}`, {
    method: 'GET',
    headers: {
      Action_Id: '600612010'
    }
  });
}

/** 查询售后管理列表(600613001) */
export async function getAfterSaleList(data: any) {
  return request(`/api/store/apply/info/${data.current}/limit/${data.pageSize}`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: '600613001'
    }
  });
}

/** 售后单审核(600613003、600613004) */
export async function auditStoreApplyInfo(data: any) {
  return request(`/api/store/audit/apply/info`, {
    method: 'PATCH',
    data,
    headers: {
      Action_Id: data.Action_Id
    }
  });
}

/** 收货入库(600613005) */
export async function inStock(data: any) {
  return request(`/api/store/return/goods`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: '600613005'
    }
  });
}

/** 查询退货物流信息(600613017) */
export async function getLogisticsInfo(apply_id: string) {
  return request(`/api/store/return/goods/${apply_id}`, {
    method: 'GET',
    headers: {
      Action_Id: '600613017'
    }
  });
}

/** 查询售后操作记录 U:提交申请 P:审核通过 I:确认收货 R:确认退款 (600613019) F:退款失败 */
export async function getAfterSaleHandleList(apply_id: string) {
  return request(`/api/store/oper/record/${apply_id}`, {
    method: 'GET',
    headers: {
      Action_Id: '600613019'
    }
  });
}

/** 查询申请单信息(600613002) */
export async function getApplyInfo(apply_id: string) {
  return request(`/api/store/apply/info/${apply_id}`, {
    method: 'GET',
    headers: {
      Action_Id: '600613002'
    }
  });
}

/** 通过订单查询售后处理记录(600613021) */
export async function getAfterSaleHandleByOrderId(order_id: string) {
  return request(`/api/store/apply/order/detail/${order_id}`, {
    method: 'GET',
    headers: {
      Action_Id: '600613021'
    }
  });
}

/** 查询售后订单详情 (600613020) */
export async function getAfterSaleDetail(apply_id: string) {
  return request(`/api/store/apply/order/goods/${apply_id}`, {
    method: 'GET',
    headers: {
      Action_Id: '600613020'
    }
  });
}
// 导出订单(600604001)
export async function downloadOrder(data: any) {
  return request(`/api/shop/order/report`, {
    method: 'POST',
    data,
    headers: {
      Action_Id: '600604001',
    }
  });
}